GtkTextIter end;
gboolean retval = FALSE;
const PangoLogAttr *attrs;
+ gint offset;
gboolean backspace_deletes_character;
g_return_val_if_fail (GTK_IS_TEXT_BUFFER (buffer), FALSE);
end = *iter;
attrs = _gtk_text_buffer_get_line_log_attrs (buffer, &start, NULL);
-
- /* For no good reason, attrs is NULL for the empty last line in
- * a buffer. Special case that here. (#156164)
- */
- if (attrs != NULL)
- {
- gint offset = gtk_text_iter_get_line_offset (&start);
- backspace_deletes_character = attrs[offset].backspace_deletes_character;
- }
- else
- backspace_deletes_character = FALSE;
+ offset = gtk_text_iter_get_line_offset (&start);
+ backspace_deletes_character = attrs[offset].backspace_deletes_character;
gtk_text_iter_backward_cursor_position (&start);
char_len = g_utf8_strlen (paragraph, -1);
byte_len = strlen (paragraph);
- g_assert (char_len > 0);
-
if (char_lenp != NULL)
*char_lenp = char_len;
}
/* The return value from this is valid until you call this a second time.
+ * Returns (char_len + 1) PangoLogAttr's, one for each text position.
*/
const PangoLogAttr *
_gtk_text_buffer_get_line_log_attrs (GtkTextBuffer *buffer,
priv = buffer->priv;
- /* special-case for empty last line in buffer */
- if (gtk_text_iter_is_end (anywhere_in_line) &&
- gtk_text_iter_get_line_offset (anywhere_in_line) == 0)
- {
- if (char_len != NULL)
- *char_len = 0;
- return NULL;
- }
-
/* FIXME we also need to recompute log attrs if the language tag at
* the start of a paragraph changes
*/
gint char_len;
const PangoLogAttr *attrs;
gint offset;
- gboolean result = FALSE;
g_return_val_if_fail (iter != NULL, FALSE);
offset = gtk_text_iter_get_line_offset (iter);
- /* char_len may be 0 and attrs will be NULL if so, if
- * iter is the end iter and the last line is empty.
- *
- * offset may be equal to char_len, since attrs contains an entry
- * for one past the end.
- */
- if (attrs != NULL && offset <= char_len)
- result = (* func) (attrs, offset, 0, char_len);
+ g_assert (offset <= char_len);
- return result;
+ return (* func) (attrs, offset, 0, char_len);
}
static gboolean
gint char_len;
const PangoLogAttr *attrs;
gint offset;
- gboolean result = FALSE;
g_return_val_if_fail (iter != NULL, FALSE);
iter, &char_len);
offset = gtk_text_iter_get_line_offset (iter);
-
- /* char_len may be 0 and attrs will be NULL if so, if
- * iter is the end iter and the last line is empty.
- */
- if (attrs != NULL)
- result = (* func) (attrs, offset, char_len, found_offset,
- already_moved_initially);
- return result;
+ return (* func) (attrs,
+ offset,
+ char_len,
+ found_offset,
+ already_moved_initially);
}
static gboolean
check_is_cursor_position ("a\r\n", 0, TRUE);
check_is_cursor_position ("a\r\n", 1, TRUE);
check_is_cursor_position ("a\r\n", 2, FALSE);
- check_is_cursor_position ("a\r\n", 3, FALSE); /* FIXME should be TRUE */
- check_is_cursor_position ("", 0, FALSE); /* FIXME should be TRUE */
+ check_is_cursor_position ("a\r\n", 3, TRUE);
+ check_is_cursor_position ("", 0, TRUE);
/* forward */
check_cursor_position ("a\r\nb", TRUE, 0, 1, TRUE);